package com.tgy.JUC.lock8;

import java.util.concurrent.TimeUnit;

/***
 * @ClassName: Test2
 * @Description:
 * @Auther: 送你一块二向箔
 * @Date: 10:59 2022/3/11
 * @version : V1.0
 */
public class Test2 {
    public static void main(String[] args) {
        //两个对象有两个锁理论上是随机的
        Phone2 phone1 = new Phone2();
        Phone2 phone2 = new Phone2();
        new Thread(()->{phone1.sendSms();},"A").start();
        new Thread(()->{phone2.call();},"B").start();

    }
}
class Phone2{
    public synchronized void sendSms(){
        try {
            TimeUnit.SECONDS.sleep(0L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("sendSms");
    }
    public synchronized void call(){

        System.out.println("call");
    }
    public  void hello(){

        System.out.println("hello");
    }
}
